﻿//popup layer 
//IE的处理方式
function isIE(num) {
	var num = num || "", tester = document.createElement('div');
	tester.innerHTML = '<!--[if IE ' + num + ']><i></i><![endif]-->';
	return !!tester.getElementsByTagName('i')[0];
}

// 显示popuplayer
function popupLayer(objClass, targetClass) {
	$("." + objClass).click(function() {
		$("#spm").show();
		var target = $("." + targetClass);
		var targetWidth = target.outerWidth();
		var targetHeight = target.outerHeight();
		if (isIE(6)) {
			$("#spm").hide();
			// $("select").hide();
			var top = $(document).scrollTop() + $(window).height() / 2;
			target.css({
				"top" : top + "px"
			});
			$(window).scroll(function() {
				var top = $(document).scrollTop() + $(window).height() / 2;
				target.css({
					"top" : top + "px"
				});
			});
		}
		target.css({
			"margin-top" : -parseInt(targetHeight / 2) + "px",
			"margin-left" : -parseInt(targetWidth / 2) + "px"
		});
		target.show();
		return false;
	});

}
// 隐藏div的操作 将子参数以一定格式转换成文本，传到后台再进行解析
function closeLayer(objClass, targetClass) {
	$("." + objClass).click(
			function() {
				oldCount = $("#params").children().children().length - 3;
				count = $(".BD_tab").children().children().length;
				var text = "@" + $("#paramValue" + oldCount + "").val() + "@";
				var oldText = "{";
				for (i = 0; i < count; i++) {
					paramChildName = ".paramChildName" + (i + 1);
					paramChildValue = ".paramChildValue" + (i + 1);
					if ($(paramChildName).val() == ""
							|| $(paramChildValue).val() == "") {
						alert("有未输入的项");
						return;
					}
					oldText = oldText + $(paramChildName).val() + ":"
							+ $(paramChildValue).val() + "&";
				}
				oldText = oldText.substring(0, oldText.length - 1);
				oldText = oldText + "}";
				$(this).parents("." + targetClass).hide(10);
				$("#spm").hide();
				$("#paramValue" + oldCount + "").val("");
				$("#paramValue" + oldCount + "").val(oldText);
			});

}